home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_08 / phillip2 / cips2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  7.7 KB  |  434 lines

  1.  
  2.    /*************************** 
  3.    * 
  4.    *   cips2.c 
  5.    *   COMPOSITE FILE COMPRISING: 
  6.    *   gpcips.c 
  7.    *   numcvrt.c 
  8.    *   mymsc.c 
  9.    * 
  10.    ***************************\ 
  11.  
  12.  
  13.  
  14.  
  15.     /******************************************************
  16.     *
  17.     *  file d:\cips\gpcips.c
  18.     *
  19.     *  Functions: This file contains
  20.     *      get_parameters
  21.     *      show_parameters
  22.     *      my_clear_text_screen
  23.     *
  24.     *  Purpose - These functions get image parameters.
  25.     *
  26.     *  External Calls:
  27.     *      intcvrt.c - get_integer
  28.     *
  29.     *  Modifications:
  30.     *      19 February 1987 - These functions were 
  31.     *           taken out of the file ip.c.
  32.     *      28 June 1990 - changed to gpcips and the
  33.     *           channel parameter was removed.
  34.     *      14 June 1993 - added the function
  35.     *           my_clear_text_screen
  36.     *
  37.     ******************************************************/
  38.  
  39.  
  40. #include "cips.h"
  41.  
  42.  
  43.  
  44.  
  45. get_parameters(il, ie, ll, le)
  46.         int *il, *ie, *le, *ll;
  47. {
  48.         int choice, not_finished;
  49.  
  50.         not_finished = 1;
  51.         while(not_finished){
  52.            show_parameters(il, ie, ll, le);
  53.            printf("\n\nEnter choice to change (enter 0 for no changes) __\b\b");
  54.            get_integer(&choice);
  55.  
  56.            switch (choice){
  57.               case 0:
  58.                  not_finished = 0;
  59.                  break;
  60.  
  61.               case 1:
  62.                  break;
  63.  
  64.               case 2:
  65.                  printf("\nEnter initial line\n___\b\b\b");
  66.                  get_integer(il);
  67.                  break;
  68.  
  69.               case 3:
  70.                  printf("\nEnter initial element\n___\b\b\b");
  71.                  get_integer(ie);
  72.                  break;
  73.  
  74.               case 4:
  75.                  printf("\nEnter last line\n___\b\b\b");
  76.                  get_integer(ll);
  77.                  break;
  78.  
  79.               case 5:
  80.                  printf("\nEnter last element\n___\b\b\b");
  81.                  get_integer(le);
  82.                  break;
  83.  
  84.            }  /* ends switch choice       */
  85.         }     /* ends while not_finished  */
  86. }             /* ends get_parameters      */
  87.  
  88.  
  89. show_parameters(il, ie, ll, le)
  90.         int *il, *ie, *le, *ll;
  91. {
  92.    printf("\n\nThe image parameters are:");
  93.    printf("\n\t2.      il = %4d", *il);
  94.    printf("\n\t3.      ie = %4d", *ie);
  95.    printf("\n\t4.      ll = %4d", *ll);
  96.    printf("\n\t5.      le = %4d", *le);
  97. }  /* ends show_parameters  */
  98.  
  99.  
  100.  
  101.  
  102.  
  103.    /*************************************************
  104.    *
  105.    *   my_clear_text_screen()
  106.    *
  107.    *   This calls Microsoft C functions to clear
  108.    *   the text screen and set a blue background
  109.    *   with gray text.
  110.    *
  111.    **************************************************/
  112.  
  113. my_clear_text_screen()
  114. {
  115.    my_setvideomode(TEXTC80);/* MSC 6.0 statements */
  116.    my_setbkcolor(1);
  117.    my_settextcolor(7);
  118.    my_clearscreen(GCLEARSCREEN);
  119. }  /* ends clear_text_screen */
  120.  
  121.     /******************************************
  122.     *
  123.     *  file d:\cips\numcvrt.c
  124.     *
  125.     *  Functions:
  126.     *     get_integer
  127.     *     get_short
  128.     *     get_long
  129.     *     get_float
  130.     *
  131.     *  Purpose: 
  132.     *     These functions read numbers from
  133.     *     the keyboard.
  134.     *
  135.     *  Modifications:
  136.     *     12 May 1993 - recreated
  137.     *
  138.     *******************************************/
  139.  
  140.  
  141.  
  142.  
  143. get_integer(n)
  144.    int *n;
  145. {
  146.    char string[80];
  147.  
  148.    gets(string);
  149.    *n = atoi(string);
  150. }
  151.  
  152.  
  153. get_short(n)
  154.    short *n;
  155. {
  156.    char string[80];
  157.  
  158.    gets(string);
  159.    *n = atoi(string);
  160. }
  161.  
  162.  
  163. get_long(n)
  164.    long *n;
  165. {
  166.    char string[80];
  167.  
  168.    gets(string);
  169.    *n = atol(string);
  170. }
  171.  
  172.  
  173. get_float(f)
  174.    float *f;
  175. {
  176.    char string[80];
  177.  
  178.    gets(string);
  179.    *f = atof(string);
  180. }
  181.  
  182.     /***********************************************
  183.     *
  184.     *  file d:\cips\mymsc.c
  185.     *
  186.     *  Functions: This file contains
  187.     *     my_clearscreen
  188.     *     my_setvideomode
  189.     *     my_setlinestyle
  190.     *     my_setcolor
  191.     *     my_setpixel
  192.     *     my_moveto
  193.     *     my_lineto
  194.     *     my_settextcolor
  195.     *     my_setbkcolor
  196.     *     my_settextposition
  197.     *     my_outtext
  198.     *     my_remappalette
  199.     *     my_map_64_shades_of_gray
  200.     *
  201.     *  Purpose:
  202.     *     This file contains subroutines that 
  203.     *     call Microsoft C 6.0 specific 
  204.     *     routines.  I put them all here in one
  205.     *     file to make it easier to port the
  206.     *     C Image Processing System software
  207.     *     to other C compilers and non-IBM PC
  208.     *     computers.
  209.     *     
  210.     *     Each subroutine in this file is a "wrapper"
  211.     *     for a Microsoft C 6.0 routine.  I put
  212.     *     the letters "my" in front of the Microsoft
  213.     *     routine name.  For example, my_clearscreen
  214.     *     calls Microsoft's _clearscreen.
  215.     *     
  216.     *     The one exception is 
  217.     *     my_map_64_shades_of_gray.
  218.     *
  219.     *  External Calls: all MSC calls
  220.     *     _clearscreen
  221.     *     _setvideomode
  222.     *     _setlinestyle
  223.     *     _setcolor
  224.     *     _setpixel
  225.     *     _moveto
  226.     *     _lineto
  227.     *     _settextcolor
  228.     *     _setbkcolor
  229.     *     _settextposition
  230.     *     _outtext
  231.     *     _remappalette
  232.     *
  233.     *  Modifications:
  234.     *     5 June 1993 - created
  235.     *
  236.     *************************************************/
  237.  
  238.  
  239.  
  240.  
  241.    /***********************************
  242.     *
  243.     *   This ifdef makes all the MSC
  244.     *   calls work.  The MSC variable
  245.     *   must be defined in cips.h.
  246.     *
  247.     ************************************/
  248.  
  249. #ifdef MSC
  250.  
  251.  
  252.  
  253. my_clearscreen()
  254. {
  255.    _clearscreen(_GCLEARSCREEN);
  256. }
  257.  
  258. my_lineto(x, y)
  259.    short x, y;
  260. {
  261.    _lineto(x, y);
  262. }
  263.  
  264. my_moveto(x, y)
  265.    short x, y;
  266. {
  267.    _moveto(x, y);
  268. }
  269.  
  270. my_outtext(text)
  271.    char *text;
  272. {
  273.    _outtext(text);
  274. }
  275.  
  276. my_remappalette(index, color)
  277.    short index;
  278.    long  color;
  279. {
  280.    _remappalette(index, color);
  281. }
  282.  
  283. my_setbkcolor(color)
  284.    long color;
  285. {
  286.    _setbkcolor(color);
  287. }
  288.  
  289. my_setcolor(color)
  290.    short color;
  291. {
  292.    _setcolor(color);
  293. }
  294.  
  295. my_setlinestyle(mode)
  296.    unsigned short mode;
  297. {
  298.    _setlinestyle(mode);
  299. }
  300.  
  301. my_setpixel(x, y)
  302.    short x, y;
  303. {
  304.    _setpixel(x, y);
  305. }
  306.  
  307. my_settextcolor(index)
  308.    short index;
  309. {
  310.    _settextcolor(index);
  311. }
  312.  
  313. my_settextposition(row, column)
  314.    short row, column;
  315. {
  316.    _settextposition(row, column);
  317. }
  318.  
  319. my_setvideomode(mode)
  320.    short mode;
  321. {
  322.    _setvideomode(mode);
  323. }
  324.  
  325.  
  326. my_map_64_shades_of_gray()
  327. {
  328.    map_64_shades_of_gray();
  329. }
  330.  
  331.  
  332.  
  333.    /*******************************************
  334.    *
  335.    *   map_64_shades_of_gray()
  336.    *
  337.    *   This function maps 256 DAC registers to
  338.    *   gray shades.  Taken from p. 73 of
  339.    *   Sutty and Blair's text on superVGA
  340.    *
  341.    ********************************************/
  342.  
  343.  
  344. map_64_shades_of_gray()
  345. {
  346.  
  347.    _asm{
  348.       mov ax,0013h ;mod 13h is 320x200x256
  349.       int 10h
  350.  
  351.       mov ah,10h   ; function 10h
  352.       mov al,1bh   ; sub function 1bh
  353.       mov bx,0h    ; first DAC register to change
  354.       mov cx,100h  ; change 256 DAC registers
  355.       int 10h
  356.  
  357.    } /* ends asm */
  358. }  /* ends map_64_shades_of_gray */
  359.  
  360. #endif /* ends ifdef MSC */
  361.  
  362.  
  363.  
  364.  
  365. #ifdef OTHERC
  366.  
  367.  
  368. my_clearscreen()
  369. {
  370. }
  371.  
  372. my_lineto(x, y)
  373.    short x, y;
  374. {
  375. }
  376.  
  377. my_moveto(x, y)
  378.    short x, y;
  379. {
  380. }
  381.  
  382. my_outtext(text)
  383.    char *text;
  384. {
  385. }
  386.  
  387. my_remappalette(index, color)
  388.    short index;
  389.    long  color;
  390. {
  391. }
  392.  
  393. my_setbkcolor(color)
  394.    long color;
  395. {
  396. }
  397.  
  398. my_setcolor(color)
  399.    short color;
  400. {
  401. }
  402.  
  403. my_setlinestyle(mode)
  404.    unsigned short mode;
  405. {
  406. }
  407.  
  408. my_setpixel(x, y)
  409.    short x, y;
  410. {
  411. }
  412.  
  413. my_settextcolor(index)
  414.    short index;
  415. {
  416. }
  417.  
  418. my_settextposition(row, column)
  419.    short row, column;
  420. {
  421. }
  422.  
  423. my_setvideomode(mode)
  424.    short mode;
  425. {
  426. }
  427.  
  428.  
  429. my_map_64_shades_of_gray()
  430. {
  431. }
  432.  
  433. #endif /* ends ifdef OTHER C */
  434.